home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1468 / alarm.frm (.txt) next >
Encoding:
Visual Basic Form  |  1996-07-20  |  3.9 KB  |  122 lines

  1. VERSION 4.00
  2. Begin VB.Form AlarmForm 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Alarm Clock"
  5.    ClientHeight    =   1065
  6.    ClientLeft      =   3750
  7.    ClientTop       =   4020
  8.    ClientWidth     =   2685
  9.    BeginProperty Font 
  10.       name            =   "MS Sans Serif"
  11.       charset         =   0
  12.       weight          =   700
  13.       size            =   8.25
  14.       underline       =   0   'False
  15.       italic          =   0   'False
  16.       strikethrough   =   0   'False
  17.    EndProperty
  18.    Height          =   1470
  19.    Icon            =   "Alarm.frx":0000
  20.    Left            =   3690
  21.    LinkTopic       =   "Form2"
  22.    LockControls    =   -1  'True
  23.    MaxButton       =   0   'False
  24.    ScaleHeight     =   71
  25.    ScaleMode       =   3  'Pixel
  26.    ScaleWidth      =   179
  27.    Top             =   3675
  28.    Width           =   2805
  29.    Begin VB.CommandButton Command1 
  30.       Caption         =   "Set Alarm"
  31.       BeginProperty Font 
  32.          name            =   "MS Sans Serif"
  33.          charset         =   0
  34.          weight          =   400
  35.          size            =   8.25
  36.          underline       =   0   'False
  37.          italic          =   0   'False
  38.          strikethrough   =   0   'False
  39.       EndProperty
  40.       Height          =   315
  41.       Left            =   120
  42.       TabIndex        =   1
  43.       Top             =   660
  44.       Width           =   2415
  45.    End
  46.    Begin VB.Timer Timer1 
  47.       Interval        =   500
  48.       Left            =   660
  49.       Top             =   60
  50.    End
  51.    Begin VB.PictureBox picTime 
  52.       Height          =   435
  53.       Left            =   120
  54.       ScaleHeight     =   375
  55.       ScaleWidth      =   2355
  56.       TabIndex        =   0
  57.       Top             =   120
  58.       Width           =   2415
  59.    End
  60. Attribute VB_Name = "AlarmForm"
  61. Attribute VB_Creatable = False
  62. Attribute VB_Exposed = False
  63. ' Sample program that comes with VB.
  64. ' Adapted for VBMaxLCD.dll by Mike Stanley
  65. Option Explicit
  66. Dim Readout As New CLCD
  67. Dim AlarmTime
  68. Const conMinimized = 1
  69. Private Sub Form_Load()
  70.      
  71.     With Readout
  72.         .Alignment = gnCENTER
  73.         .ShowUnlitSegments = False
  74.         .ForeColor = &H8080&
  75.         Set .Container = picTime
  76.     End With
  77.     AlarmTime = ""
  78. End Sub
  79. Private Sub Form_Resize()
  80.     If WindowState = conMinimized Then      ' If form is minimized, display the time in a caption.
  81.         SetCaptionTime
  82.     Else
  83.         Caption = "Alarm Clock"
  84.     End If
  85. End Sub
  86. Private Sub SetCaptionTime()
  87.     Caption = Format(Time, "Medium Time")   ' Display time using medium time format.
  88. End Sub
  89. Private Sub Form_Unload(Cancel As Integer)
  90.     Set Readout = Nothing
  91.     Set AlarmForm = Nothing
  92. End Sub
  93. Private Sub Timer1_Timer()
  94. Static AlarmSounded As Integer
  95.     If Readout.Caption <> CStr(Time) Then
  96.         ' It's now a different second than the one displayed.
  97.         If Time >= AlarmTime And Not AlarmSounded Then
  98.             Beep
  99.             MsgBox "Alarm at " & Time
  100.             AlarmSounded = True
  101.         ElseIf Time < AlarmTime Then
  102.             AlarmSounded = False
  103.         End If
  104.         If WindowState = conMinimized Then
  105.             ' If minimized, then update the form's Caption every minute.
  106.             If Minute(CDate(Caption)) <> Minute(Time) Then SetCaptionTime
  107.         Else
  108.             ' Otherwise, update the label Caption in the form every second.
  109.             Readout.Caption = Time
  110.         End If
  111.     End If
  112. End Sub
  113. Private Sub Command1_Click()
  114.     AlarmTime = InputBox("Enter alarm time", "VB Alarm", AlarmTime)
  115.     If AlarmTime = "" Then Exit Sub
  116.     If Not IsDate(AlarmTime) Then
  117.         MsgBox "The time you entered was not valid."
  118.     Else                                    ' String returned from InputBox is a valid time,
  119.         AlarmTime = CDate(AlarmTime)        ' so store it as a date/time value in AlarmTime.
  120.     End If
  121. End Sub
  122.